package com.jindu.producer.finance.jpa;

import com.jindu.producer.finance.model.FFiscalResultEntity;
import com.jindu.producer.finance.model.FReportEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author jarvischang
 */
@Transactional
public interface ReportJpa extends JpaRepository<FReportEntity,Long>,JpaSpecificationExecutor {

    /**
     * 根据id 查询 单个实体
     * @param id
     * @return
     */
    FReportEntity findById(String id);

    /**
     * 根据产品id 查询数据
     * @param productId
     * @param pageable
     * @return
     */
    Page<FReportEntity> findByProductId(String productId,Pageable pageable);

    /**
     * 根据id删除数据
     * @param id
     * @return
     */
    @Modifying
    @Query("delete from FFiscalResultEntity where id = ?1 ")
    int deleteById(String id);

}
